package com.example.controller;

import com.example.bean.DataBean;
import com.example.service.DataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/data")
public class DataController {

    @Autowired
    public DataController(DataService dataService) {
        this.dataService = dataService;
    }
    DataService dataService;

    @GetMapping("/add")
    public String add(String name){
        return dataService.addOneData(name);
    }

    @GetMapping("/list")
    public List<DataBean> getList(){
        return dataService.getTwoData();
    }
}
